import 'package:flutter/material.dart';

void main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
        home: Scaffold(
            appBar: AppBar(title: Text('Flutter Demo')),
            //body内容多抽离出去
            body: HomeContent()));
  }
}

//body
class HomeContent extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return LayoutDemo();
  }
}

//layoutdemo
class LayoutDemo extends StatelessWidget{
  @override
  Widget build(BuildContext context) {
    return IconContainer(Icons.search, color: Colors.black);
  }
}

class IconContainer extends StatelessWidget {

  double size = 32.0;
  Color color = Colors.red;
  IconData icon;

  IconContainer(this.icon, {this.color, this.size});

  @override
  Widget build(BuildContext context) {
    return Container(
      height: 100,
      width: 100,
      color: Colors.red,
      child: Center(
        child: Icon(this.icon, size: this.size, color: this.color), 
      ), 
    );
  }
  
}